home *** CD-ROM | disk | FTP | other *** search
- Path: news.cern.ch!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: Question about C compiler
- Date: 18 Apr 96 10:09:40 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.829822180@news.cern.ch>
- References: <1996Apr16.175344.6042@lafn.org>
- NNTP-Posting-Host: ues5.cern.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
- X-Newsreader: NN version 6.5.0 #18 (NOV)
-
- In <1996Apr16.175344.6042@lafn.org> av871@lafn.org (Karl Chen) writes:
-
-
- > In C and C++ ,there is a way to allocate and dealloacte memory
- >dynamically ( in C,using malloc() and free(),In C++,using new and delete)
- >.I heard from a book
-
- Wow, you have a talking book! :-)
-
- >that some compiler do not delete the pointer after
- >deallocation,is this true?Why they don't do this ?
-
- To answer these questions, I would need to know what you mean by
- "deleting a pointer". If you mean, setting the pointer to NULL after
- deallocation, the answer is obvious if you actually try to think at it
- for one minute.
-
- Clue1: reading the FAQ may help.
-
- Clue2: function arguments are passed by value in C. (Yes, a smartass
- could argue that free() is a special case and the compiler could legally
- pass its argument by address or generate the right code to nullify the
- pointer right after the free() call, but this is not what happens in the
- real world.)
-
- >What about Boland C++
- >?
-
- "Boland C++" is no exception. It treats free() as an ordinary function.
-
- >Can anyone give me a advice ?
-
- If it's important to you, set the pointer to NULL right after calling
- free().
-
- > Thankx !!!Please e-mail me
-
- If you're too lazy to scan the newsgroup for answers, you don't deserve
- them.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-